load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "kv",
    srcs = [
        "allocator.go",
        "base.go",
        "context.go",
        "kv2sql.go",
        "session.go",
        "sql2kv.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/lightning/backend/kv",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/logutil",
        "//pkg/errctx",
        "//pkg/expression",
        "//pkg/expression/context",
        "//pkg/expression/contextsession",
        "//pkg/expression/contextstatic",
        "//pkg/infoschema/context",
        "//pkg/kv",
        "//pkg/lightning/backend/encode",
        "//pkg/lightning/common",
        "//pkg/lightning/log",
        "//pkg/lightning/manual",
        "//pkg/lightning/metric",
        "//pkg/lightning/verification",
        "//pkg/meta/autoid",
        "//pkg/meta/model",
        "//pkg/parser/mysql",
        "//pkg/planner/context",
        "//pkg/sessionctx",
        "//pkg/sessionctx/stmtctx",
        "//pkg/sessionctx/variable",
        "//pkg/table",
        "//pkg/table/context",
        "//pkg/table/contextimpl",
        "//pkg/table/tables",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util/chunk",
        "//pkg/util/codec",
        "//pkg/util/context",
        "//pkg/util/intest",
        "//pkg/util/mathutil",
        "//pkg/util/redact",
        "//pkg/util/timeutil",
        "//pkg/util/topsql/stmtstats",
        "@com_github_docker_go_units//:go-units",
        "@com_github_pingcap_errors//:errors",
        "@org_uber_go_zap//:zap",
        "@org_uber_go_zap//zapcore",
    ],
)

go_test(
    name = "kv_test",
    timeout = "short",
    srcs = [
        "allocator_test.go",
        "base_test.go",
        "context_test.go",
        "kv2sql_test.go",
        "session_internal_test.go",
        "sql2kv_test.go",
    ],
    embed = [":kv"],
    flaky = True,
    race = "on",
    shard_count = 21,
    deps = [
        "//pkg/ddl",
        "//pkg/errctx",
        "//pkg/expression/context",
        "//pkg/expression/contextstatic",
        "//pkg/kv",
        "//pkg/lightning/backend/encode",
        "//pkg/lightning/common",
        "//pkg/lightning/log",
        "//pkg/lightning/verification",
        "//pkg/meta/autoid",
        "//pkg/meta/model",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/planner/core",
        "//pkg/sessionctx/stmtctx",
        "//pkg/sessionctx/variable",
        "//pkg/table",
        "//pkg/table/context",
        "//pkg/table/tables",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util/context",
        "//pkg/util/deeptest",
        "//pkg/util/mock",
        "//pkg/util/rowcodec",
        "//pkg/util/timeutil",
        "@com_github_docker_go_units//:go-units",
        "@com_github_pingcap_errors//:errors",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_zap//:zap",
        "@org_uber_go_zap//zapcore",
    ],
)
